<?php
/**
 * Copyright (C) 2013 Pablo Sepúlveda P. <psep.pentauc@gmail.com>
 * 
 * This file is part of gAbstract.
 * WarpIT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * gAbstract is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with gAbstract.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Clase final que contiene métodos estáticos
 * para formatear nombres de clases y métodos.
 * 
 * @author psep
 * @version 1.0
 * @package gAbstract
 * @copyright Copyright (c) 2013 Pablo Sepúlveda P.
 * @license GNU GPLv3 or later
 * @link http://www.psep.cl
 */
final class NameUtils {
	
	/**
	 * Método que formatea un nombre de entrada como
	 * parámetro y da nombre formal de objeto.
	 * 
	 * @param String $objectName
	 * @return String $formalObjectName
	 */
	public static function formalObjectName($objectName){
		return substr_replace($objectName, strtolower(substr($objectName, 0, 1)), 0, 1);
	}
	
	/**
	 * Método que formatea un nombre informal a uno
	 * comenzando con letra mayúscula, ideal para 
	 * nombre de clases.
	 * 
	 * @param String $informalName
	 * @return String $formalName
	 */
	public static function formalName($informalName){
		return substr_replace($informalName, strtoupper(substr($informalName, 0, 1)), 0, 1);
	}
	
	/**
	 * Retorna nombre formal del tipo de un atributo
	 * formateado como string para el cast.
	 * 
	 * @param String
	 * @return String
	 */
	public static function castName($value){
		$cast = ObjectUtil::getTypeDB($value);
		
		if($cast != null){
			return "(".$cast.") ";
		}
		
		return null;
	}
	
}

?>